Skip to content

Added useFlowQueryRaw hook #2523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 19, 2025
Merged

Added useFlowQueryRaw hook #2523

merged 6 commits into from
Jun 19, 2025

Conversation

mfbz
Copy link
Contributor

@mfbz mfbz commented Jun 17, 2025

Close #2407

@mfbz mfbz requested a review from a team as a code owner June 17, 2025 21:14
Copy link

changeset-bot bot commented Jun 17, 2025

🦋 Changeset detected

Latest commit: 43cb3d8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@onflow/fcl-core Minor
@onflow/fcl Minor
@onflow/kit Major
@onflow/fcl-react-native Patch
@onflow/fcl-wc Major
@onflow/fcl-ethereum-provider Major
@onflow/fcl-rainbowkit-adapter Major
@onflow/fcl-wagmi-adapter Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chasefleming chasefleming requested a review from Copilot June 17, 2025 23:05
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new hook, useFlowQueryRaw, to execute a Cadence script and obtain its raw query response without decoding it. Key changes include:

  • Implementation of the useFlowQueryRaw hook integrating with react-query and fcl.rawQuery.
  • Comprehensive tests for various scenarios including error handling, argument updates, and disabling queries.
  • Updates and re-exports across related files to support the new hook.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/kit/src/hooks/useFlowQueryRaw.ts New hook implementation for executing raw queries
packages/kit/src/hooks/useFlowQueryRaw.test.ts Added tests covering multiple use cases for the new hook
packages/kit/src/hooks/index.ts Exports new hook
packages/kit/src/mocks/fcl.ts Added mock for rawQuery
packages/fcl/src/fcl.ts Updated export for rawQuery
packages/fcl-core/src/fcl-core.ts Updated export for rawQuery
packages/fcl-core/src/exec/raw-query.ts New implementation of rawQuery function
packages/fcl-core/src/exec/query.ts Updated query function to work with rawQuery
packages/fcl-core/src/exec/query.js Removal of outdated query implementation
.changeset/wicked-bikes-peel.md Changeset documenting the new hook

Copy link
Member

@chasefleming chasefleming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this tested with harness?

@chasefleming chasefleming self-requested a review June 17, 2025 23:37

// Encode the arguments to a JSON-CDC object so they can be deterministically
// serialized and used as the query key.
const encodedArgs = args?.(fcl.arg, fcl.t)?.map((x: any) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the useFlowQuery file as well. Can we move it somewhere its shared?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, created encodeQueryArgs function and shared between hooks!

@mfbz
Copy link
Contributor Author

mfbz commented Jun 18, 2025

Is this tested with harness?

Yes, tested!

@mfbz mfbz requested a review from chasefleming June 18, 2025 07:49
@mfbz mfbz requested a review from jribbink June 19, 2025 10:05
@mfbz mfbz merged commit 6076b0b into master Jun 19, 2025
1 check passed
@mfbz mfbz deleted the mfbz/use-flow-query-raw branch June 19, 2025 21:35
@github-actions github-actions bot mentioned this pull request Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useFlowQueryRaw or option to return non-decoded data
3 participants